package com.iot.server.service.impl;

import com.iot.core.exception.BDException;
import com.iot.server.dao.SysRoleDOMapper;
import com.iot.server.domain.SysRoleDO;
import com.iot.server.service.RoleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wuzt
 * Date 2020/6/23 10:14
 * Version 1.0
 * @ClassName RoleServiceImpl
 * Description
 **/
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    SysRoleDOMapper sysRoleDOMapper;

    @Override
    public List<SysRoleDO> selectRolesByUserId(String userId) {
        if (StringUtils.isEmpty(userId)) {
            throw new BDException("用户id不能为空");
        }
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        return sysRoleDOMapper.listByMap(params, "selectRolesByUserId");
    }
}
